//app.js
const ald = require('./utils/ald-stat.js')

const wechat = require("./utils/wechat.js");
const Storage = require("./utils/storage.js");
const config = require("./utils/config.js");
const com = require("./utils/commonRequest.js");
const session = require("./utils/session.js");
const cart = require("./utils/cart.js");

import {
  user_weixinLogin
} from "./utils/api";
// var push = require('./utils/pushsdk.js');

App({
  onLaunch: function(options) {
    var that = this;
    wx.getSystemInfo({
      success: function(res) {
        // console.log(res.model);
        if (res.model.indexOf('iphonrx') > -1 || res.model.indexOf('iPhone X') > -1) {
          that.globalData.isIphoneX = true;
        }
      }
    })

    var sourceType;
    var sourceId;

    if (options.query.scene) {
      const scene = decodeURIComponent(options.query.scene);
      var params = scene.split(',');
      sourceType = params[0];
      sourceId = params[1];

      this.globalData.sourceType = sourceType;
      this.globalData.sourceId = sourceId;
    }

    if (options.query.sourceType) {
      sourceType = options.query.sourceType;
      this.globalData.sourceType = sourceType;
    }
    if (options.query.sourceId) {
      sourceId = options.query.sourceId;
      this.globalData.sourceId = sourceId;
    }

    var that = this;
    // session.login(function(usr,sourceType,sourceId){
    //   that.globalData.userInfo = usr;
    //   com.updateUnRead();
    // })
    // cart.updateCount();
  },
  globalData: {
    userInfo: {},
    isIphoneX: false,
    applogo: 'https://img.lingxing.site/img/newlogo1.jpg'
  },
});